/*
* created by Administrator on 2018/12/6
* 好的代码像粥一样,是得用时间和精力熬的。
*/
// 主键
Vue.component('app-list', {
    template: '#app-list',
    data: function () {
        return {
            userData: Mock.mock({
                'data|10': [{
                    name: '@cname',
                    gender: '@boolean',
                    city: '@city',
                    phoneNumber: /^1[345789]\d{9}$/,
                    age: '@integer(16,30)',
                }]
            }).data,
            // selectedKey: -1
        }
    },
    methods: {
        clickToDel(index) {
            this.userData.splice(index, 1);
        },
    },
    computed: {
        filterUser: function () {
            let selectedFns = {
                '-1': () => true,
                0: value => value.gender,
                1: value => !value.gender,
                2: value => value.age < 20,
                3: value => /^1[3458]/.test(value.phoneNumber),
            };
            return this.userData.filter(selectedFns[this.foo]||'-1');
        }
    },
    props:['foo'],
});
